cinema();
function cinema(){
    var token = localStorage.getItem("token");
    $.ajax({
        type: "get",
        url: "../cinema",
        headers: {'token': token},
        success: function (result) {
            var loginCustomer=result.data.loginCustomer;
            if (loginCustomer != null){
                var customerId = loginCustomer.customerId;
                var url = "/demo/order?customerId="+customerId;
                $(".head-user").hide();
                $(".user-menu").html('<li class="text"><a href='+url+'>个人中心</a></li>\n' +
                    '                 <li class="text" id="return"><button style="border: none">退出登录</button></li>');
                $(".user-info").show();
            }else {
                $(".head-user").show();
                $(".user-info").hide();
            }
            $("#return").click(function (){
                var token = localStorage.removeItem("token");
                window.location.href = "http://localhost:8080/demo/index.jsp";
            })
            $(".movie-list").html("");
            console.log(result.data)
            var data = result.data.hotMovieList;
            for (var i =0;i<data.length;i++){
                console.log(data.length);
                var movieId = data[i].movieId;
                var movieCname =data[i].movieCname;
                var moviePicture = data[i].moviePicture;
                var movieEle =
                    "<li class=\"poster-item\" >\n" +
                    "                        <img class=\"img-wrap\" src=\"../"+moviePicture+"\" alt=\"\">\n" +
                    "                        <span class=\"tetle-wrap\">"+movieCname+"</span>\n" +
                    "                        <a class=\"wrap\" href=\"../MovieDetail?movieId="+movieId+"\">\n" +
                    "                            <div class=\"btn-wrap\">\n" +
                    "                                <span >查看详情</span>\n" +
                    "                            </div>\n" +
                    "                        </a>\n" +
                    "                        <a class=\"wrap\" href=\"../movieSchedule?movieId="+movieId+"\">\n" +
                    "                            <div class=\"btn-wrap\">\n" +
                    "                                <span >立即购买</span>\n" +
                    "                            </div>\n" +
                    "                        </a>\n" +
                    "                    </li>"

                $(".movie-list").append(movieEle);
            }
        }
    })
}

